package com.ruoyi.web.controller.order;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.order.domain.MesDetectNode;
import com.ruoyi.order.service.IMesDetectNodeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 检测节点Controller
 * 
 * @author ruoyi
 * @date 2025-02-26
 */
@RestController
@RequestMapping("/order/node")
public class MesDetectNodeController extends BaseController
{
    @Autowired
    private IMesDetectNodeService mesDetectNodeService;

    /**
     * 查询检测节点列表
     */
    @PreAuthorize("@ss.hasPermi('order:node:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesDetectNode mesDetectNode)
    {
        startPage();
        List<MesDetectNode> list = mesDetectNodeService.selectMesDetectNodeList(mesDetectNode);
        return getDataTable(list);
    }

    /**
     * 查询检测节点所有数据
     */
    @GetMapping("/listAll")
    public TableDataInfo list()
    {
        List<MesDetectNode> list = mesDetectNodeService.selectMesDetectNodeList(new MesDetectNode());
        return getDataTable(list);
    }

    /**
     * 导出检测节点列表
     */
    @PreAuthorize("@ss.hasPermi('order:node:export')")
    @Log(title = "检测节点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesDetectNode mesDetectNode)
    {
        List<MesDetectNode> list = mesDetectNodeService.selectMesDetectNodeList(mesDetectNode);
        ExcelUtil<MesDetectNode> util = new ExcelUtil<MesDetectNode>(MesDetectNode.class);
        util.exportExcel(response, list, "检测节点数据");
    }

    /**
     * 获取检测节点详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:node:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mesDetectNodeService.selectMesDetectNodeById(id));
    }

    /**
     * 新增检测节点
     */
    @PreAuthorize("@ss.hasPermi('order:node:add')")
    @Log(title = "检测节点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesDetectNode mesDetectNode)
    {
        return toAjax(mesDetectNodeService.insertMesDetectNode(mesDetectNode));
    }

    /**
     * 修改检测节点
     */
    @PreAuthorize("@ss.hasPermi('order:node:edit')")
    @Log(title = "检测节点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesDetectNode mesDetectNode)
    {
        return toAjax(mesDetectNodeService.updateMesDetectNode(mesDetectNode));
    }

    /**
     * 删除检测节点
     */
    @PreAuthorize("@ss.hasPermi('order:node:remove')")
    @Log(title = "检测节点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mesDetectNodeService.deleteMesDetectNodeByIds(ids));
    }
}
